<template>
  <view :style="themeColor">
    <view class="page">
      <view class="flex benben-position-layout flex flex-wrap align-center wanfoWall_flex_0"
        :style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx', }">
        <view class='flex flex-wrap align-center justify-between flex-sub wanfoWall_fd0_0'>
          <view class='flex flex-wrap align-center wanfoWall_fd0_0_c0' @tap.stop="handleJumpDiy" data-type="back"
            data-url="1">
            <text class='fu-iconfont2  wanfoWall_fd0_0_c0_c0'>&#xE794;</text>
          </view>
          <view class='flex flex-wrap align-stretch justify-center'>
            <text class='wanfoWall_fd0_0_c1_c0'>{{title}}</text>
          </view>
          <view v-if="isup==0" class='flex flex-wrap align-center justify-end wanfoWall_fd0_0_c0'
            @tap.stop="almsDataFunc()">
            <text class='wanfoWall_fd0_0_c2_c0'>{{$t('我要布施')}}</text>
          </view>
          <view v-if="isup==1" class='flex flex-wrap align-center justify-end wanfoWall_fd0_0_c0'>
          </view>
        </view>

      </view>
      <view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
      <!---flex布局flex布局开始-->
      <view class="flex benben-flex-layout flex-wrap align-center wanfoWall_flex_1">
        <benben-select-diy ref="showSelectPopup1703585422782" class-name='flex flex-wrap align-center flex'
          :items.sync="wallList" v-model="id" default-type="aid" default-label="name" :allow-cancel='false' type="radio"
          :disabled='false'>
          <template v-for='(item,key0) in wallList'>
            <view v-if="item.isSelected" class='flex flex wanfoWall_fd1_0_c0' :key="key0"
              @tap="$refs.showSelectPopup1703585422782.tapHandle(key0)">
              <view class='flex flex-direction flex-wrap align-center'>
                <image class='wanfoWall_fd1_0_c0_c0_c0' mode="aspectFit" :src='STATIC_URL+"16.png"'></image>
                <text class='wanfoWall_fd1_0_c0_c0_c1' v-if="item.check==0">{{item.name}}</text>
                <image class='wanfoWall_fd1_0_c0_c0_c0_img' v-else mode="aspectFit" :src='STATIC_URL+"16.png"'></image>
              </view>
            </view>
            <view v-else class='flex flex wanfoWall_fd1_0_c0' :key="key0"
              @tap="$refs.showSelectPopup1703585422782.tapHandle(key0)">
              <view class='flex flex-direction flex-wrap align-center'>
                <image class='wanfoWall_fd1_0_c0_c0_c0' mode="aspectFit" :src='STATIC_URL+"16.png"'></image>
                <text class='wanfoWall_fd1_0_c1_c0_c1' v-if="item.check==0">{{item.name}}</text>
                <image class='wanfoWall_fd1_0_c0_c0_c0_img' v-else mode="aspectFit" :src='STATIC_URL+"16.png"'></image>
              </view>
            </view>
          </template></benben-select-diy>
      </view>

      <!---flex布局flex布局结束-->
      <view class="flex flex-direction flex-wrap align-stretch benben-position-layout flex wanfoWall_flex_2">
        <view class='flex flex-wrap align-center justify-between flex-sub wanfoWall_fd2_0'>
          <button class='wanfoWall_fd2_0_c0' v-if="current_page!=1" @click.stop="prePage">{{$t('上一页')}}</button>
          <button class='' style="width: 160rpx;line-height: 80rpx;" v-else></button>
          <view class='flex flex-wrap align-center'>
            <text class='wanfoWall_fd2_0_c1_c0'>{{current_page}}</text>
            <text class='wanfoWall_fd2_0_c1_c0'>/</text>
            <text class='wanfoWall_fd2_0_c1_c0'>{{total}}</text>
          </view>
          <button class='wanfoWall_fd2_0_c2' @click='nextPage' v-if="current_page!=total">{{$t('下一页')}}</button>
          <button class='' style="width: 160rpx;line-height: 80rpx;" v-else></button>
        </view>

      </view>
      <view :style="{height: '140rpx'}"></view>


    </view>
  </view>
</template>
<script>
  import {
    validate
  } from '@/common/utils/validate.js';
  import {
    API_BASE_URL,
    SYSTEM_CONFIG
  } from '@/common/config.js'
  export default {
    components: {},


    data() {
      return {
        "wallList": [],
        total: '',
        current_page: '',
        "id": "",
        page: 1,
        pagesize: 25,
        list_rows: 25,
        type: '',
        isup: 0,
        title: ''
      };
    },
    computed: {
      themeColor() {
        return this.$store.getters.themeColor
      },

    },
    watch: {},
    onLoad(options) {
      let {
        id,
        type,
        name
      } = options
      if (id !== undefined) this.id = id
      if (type !== undefined) this.type = type
      if (name !== undefined) this.title = name
      this.getWallFunc()

    },
    onUnload() {

    },
    onReady() {

    },
    onShow() {
      if (uni.getSystemInfoSync().platform == 'ios') {
        this.$api.post(global.apiUrls.post64534cbb2c352, {
          code: 'is_sale',
          appVersion: SYSTEM_CONFIG.appVersion
        }).then(res => {
          this.isup = res.data.data
        })
      }
    },
    onHide() {

    },
    onResize() {

    },
    onPullDownRefresh() {

    },
    onReachBottom(e) {

    },
    onPageScroll(e) {

    },
    methods: {
      // 上一页
      prePage() {
        this.id = ''
        if (this.page > 1) {
          this.page--
          this.getWallFunc()
        }
      },
      // 下一页
      nextPage() {
        this.id = ''
        if (this.page < this.total) {
          this.page++
          this.getWallFunc()
        }
      },
      //获取万佛墙
      async getWallFunc() {
        //请求方法
        //数据验证
        let urls = ''
        if (this.type == 'user') {
          urls = global.apiUrls.post65a73c7d9ca79
        } else {
          urls = global.apiUrls.post658965d1b0bbc
        }
        let datawallList = await this.$api.get(urls, {
          // aid: this.id
          page: this.page,
          pagesize: this.pagesize,
          list_rows: this.list_rows,
        });

        if (datawallList.data.code != 1) {
          this.$message.info(datawallList.data.msg);
          return
        }
        let infowallList = datawallList.data.data;
        this.wallList = infowallList.data
        this.current_page = datawallList.data.data.current_page
        this.total = datawallList.data.data.last_page

      },
      //我要布施
      almsDataFunc() {
        // if (!validate(this.id, 'require')) {
        //   this.$message.info(global.i18n.t('请选择布施人'));
        //   return false;
        // }
        if (this.id) {
          let check = this.wallList.filter(item => item.aid == this.id)[0].check
          let titles = this.wallList.filter(item => item.aid == this.id)[0].msg
          if (check == 1) {
            this.$message.info(titles);
            return false;
          }
        }

        let iddd = '0'
        if (this.id) {
          iddd = this.id
        }
        this.$urouter.navigateTo(`/pages/shouye/wantAlms/wantAlms?order=&id=${iddd}&state=1`);
      }
    }
  };
</script>
<style lang="scss" scoped>
  .container-item {}

  .wanfoWall_fd1_0_c0_c0_c0_img {
    width: 32rpx;
    height: 32rpx;
    margin: 16rpx 0rpx 0rpx 0rpx;
  }

  .wanfoWall_fd1_0_c1_c0_c1 {
    color: #333333;
    font-size: 26rpx;
    font-weight: 500;
    line-height: 32rpx;
    margin: 16rpx 0rpx 0rpx 0rpx;
  }

  .page {
    width: 100vw;
    overflow-x: hidden;
    min-height: calc(100vh - var(--window-bottom));
    background: rgba(247, 243, 237, 1);
    background-size: 100% auto;
  }

  .wanfoWall_flex_0 {
    border-bottom: 1px solid #eee;
    background: rgba(247, 243, 237, 1);
    width: 750rpx;
    height: 88rpx;
    overflow: hidden;
    z-index: 10;
    top: 0rpx;
    background-size: 100% auto !important;
  }

  .wanfoWall_fd0_0_c2_c0 {
    color: #333333;
    font-size: 28rpx;
    font-weight: 500;
    line-height: 32rpx;
  }

  .wanfoWall_fd0_0_c1_c0 {
    font-size: 36rpx;
    font-weight: 700;
    color: #333333;
    line-height: 50rpx;
  }

  .wanfoWall_fd0_0_c0_c0 {
    font-size: 36rpx;
    color: #333;
  }

  .wanfoWall_fd0_0_c0 {
    width: 120rpx;
  }

  .wanfoWall_fd0_0 {
    padding: 0rpx 32rpx 0rpx 32rpx;
  }

  .wanfoWall_flex_1 {
    padding: 32rpx 15rpx 0rpx 32rpx;
  }



  .wanfoWall_fd1_0_c0_c0_c1 {
    color: rgba(251, 42, 37, 1);
    font-size: 26rpx;
    font-weight: 500;
    line-height: 32rpx;
    margin: 16rpx 0rpx 0rpx 0rpx;
  }

  .wanfoWall_fd1_0_c0_c0_c0 {
    width: 124rpx;
    height: 124rpx;
    border-radius: 0rpx 0rpx 0rpx 0rpx;
  }

  .wanfoWall_fd1_0_c0 {
    margin: 24rpx 15rpx 0rpx 0rpx;
  }

  .wanfoWall_flex_2 {
    background: rgba(235, 228, 217, 1);
    width: 750rpx;
    height: 140rpx;
    overflow: hidden;
    z-index: 10;
    bottom: calc(0rpx + var(--window-bottom));
    background-size: 100% auto;
  }

  .wanfoWall_fd2_0_c2 {
    border: 1px solid rgba(145, 47, 34, 1);
    background: rgba(235, 228, 217, 1);
    border-radius: 44rpx;
    width: 160rpx;
    line-height: 80rpx;
    font-size: 32rpx;
    color: rgba(145, 47, 34, 1);
    background-size: 100% auto;
  }

  .wanfoWall_fd2_0_c1_c0 {
    color: #333333;
    font-size: 32rpx;
    font-weight: 500;
    line-height: 53rpx;
  }

  .wanfoWall_fd2_0_c0 {
    border: 1px solid rgba(152, 112, 64, 1);
    background: rgba(235, 228, 217, 1);
    border-radius: 44rpx;
    width: 160rpx;
    line-height: 80rpx;
    font-size: 32rpx;
    color: rgba(152, 112, 64, 1);
    background-size: 100% auto;
  }

  .wanfoWall_fd2_0 {
    padding: 0rpx 32rpx 0rpx 32rpx;
  }
</style>
